from flask import Flask,request
from flask import render_template

app = Flask(__name__)

# 1.登记路由： route
@app.route('/',methods=["GET","POST"])    # /代表根路径，首页,相对路径

# 2.视图函数，返回值为页面的显示信息，数据信息有文本txt，html，json等格式
#                           可改为return '<h1>Hello World!</h1>'
# def hello_world():  # put application's code here
#     return 'Hello World!'
def hello_world():  # put application's code here
    return 'hello,world!'

@app.route('/index',methods=["GET","POST"])
def hello_use():  # put application's code here

    return render_template("index.html")

@app.route('/result',methods=["GET","POST"])
def build_name():
    # 用户输入的信息是在request中的
    first_name =  request.form["firstname"]
    last_name = request.form["lastname"]
    full_name = first_name.title() +" "+ last_name.title()
    return render_template("fullname_result.html",
                           fullname = full_name)


if __name__ == '__main__':
    app.run()
